/*
 * SalleParisDAO
 */
package fr.cinescope2014.daos;

import fr.cinescope2014.modeles.SalleParis;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author pascal
 */
public class SalleParisDAO {

    private Connection icn;

    public SalleParisDAO(Connection icn) {
        this.icn = icn;
    }

    public List<SalleParis> selectAll() {
        List<SalleParis> listeSallesParis = new ArrayList();

        // Une vue
        String lsSQL = "SELECT * FROM salles_paris ORDER BY nom_arrondissement, nom_cinema";
        try {
            PreparedStatement lpst = icn.prepareStatement(lsSQL);
            ResultSet lrs = lpst.executeQuery();
            SalleParis sp;
            while (lrs.next()) {
                // SalleParis(String codeArrondissement, String nomArrondissement, String codeCinema, String nomCinema, String titreFilm, String versionProjection, String horairesProjection) {
                sp = new SalleParis(lrs.getString(1),  lrs.getString(2), lrs.getString(3), lrs.getString(4), lrs.getString(5), lrs.getString(6), lrs.getString(7));
                listeSallesParis.add(sp);
            }
            lrs.close();
            lpst.close();
        } catch (SQLException ex) {
            System.out.println(ex);
        }

        return listeSallesParis;
    }
}
